import { defineStore } from 'pinia'
import { useCounterStore } from './counter'
import { computed, ref } from 'vue'

// 1. 获取其他Store的实例
const counterStore = useCounterStore()

export const useTestStore = defineStore(
  'test',
  () => {
    const testState = ref('test state')

    // 2. 在自己的 Store 入口函数中直接使用

    const tripleCount = computed(() => {
      // count 值在 counter Store 中
      return counterStore.count * 3
    })

    return { tripleCount, testState }
  },
  {
    persist: true,
  }
)
